import utils from '~/utils';

export default class ErrorCodeConstant {
    static readonly CLOSE = -2;
    static readonly INVALID = -1;
    static readonly FAIL = 0;
    static readonly SUCCESS = 200;
    static readonly NO_AUTH = 401;
    static readonly RATE_LIMIT = 4011;

    // 1001 - 1500 用户相关
    static readonly USER_NOT_AUTH = 1001;
    static readonly USER_NOT_EXISTS = 1011;
    static readonly USER_IS_BAN = 1012;
    static readonly USER_ACCESS_UPDATE = 1013;
    static readonly USER_NOT_MENU_AUTH = 1014;

    // 1501 - 2000 租户相关
    static readonly CORPORATION_NOT_EXISTS = 1501;
    static readonly CORPORATION_EXPIRE = 1502;
    static readonly CORPORATION_STOP = 1503;
    static readonly CORPORATION_PROJECT_NUM_LIMIT = 1504;
    static readonly CORPORATION_PROJECT_AREA_LIMIT = 1505;

    // 2001 - 2500 租客联系相关
    static readonly MERCHANT_PERSONNEL_UNBIND_PHONE = 2001;

    // 3001 - 3500 招商相关
    static readonly BUSINESS_BUILDING_INVALID = 3001;

    static getDesc(code: number | null): any {
        let data = {};
        data[this.CLOSE] = '功能关闭，暂不开放';
        data[this.INVALID] = '未知错误';
        data[this.FAIL] = '失败';
        data[this.SUCCESS] = '成功';
        data[this.NO_AUTH] = '登录失效';
        data[this.RATE_LIMIT] = '不可重复提交';

        // 1001 - 1500 用户相关
        data[this.USER_NOT_AUTH] = '暂无权限';
        data[this.USER_NOT_EXISTS] = '员工不存在';
        data[this.USER_IS_BAN] = '已被禁用，请联系管理员';
        data[this.USER_ACCESS_UPDATE] = '员工角色权限发生变更';
        data[this.USER_NOT_MENU_AUTH] = '员工无菜单权限，请联系管理员';

        // 1501 - 2000 商业相关
        data[this.CORPORATION_NOT_EXISTS] = '租户不存在';
        data[this.CORPORATION_EXPIRE] = '您的企业已到期，请联系您的专属技术顾问！';
        data[this.CORPORATION_STOP] = '租户已被暂停使用';
        data[this.CORPORATION_PROJECT_NUM_LIMIT] = '租户项目数量受限';
        data[this.CORPORATION_PROJECT_AREA_LIMIT] = '租户项目面积受限';

        // 2001 - 2500 租客联系相关
        data[this.MERCHANT_PERSONNEL_UNBIND_PHONE] = '租客联系人未绑定手机号';

         // 3001 - 3500 招商相关
        data[this.BUSINESS_BUILDING_INVALID] = '房源已失效';

        if (code === null) {
            return data;
        }

        return utils.text.isEmpty(data[code]) ? '-' : data[code];
    }
}